let utils = require('../../../utils/util.js')

// component/common/description/description.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    isshow: {
      type: Boolean
    },
    current: {
      type: Number,
      default: 0
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    descList: [],
    indicatorDots: true,
    autoplay: false,
    interval: 5000,
    duration: 1000,
    indicatorActiveColor: "#f9fe36",
    indicatorColor: "#ccc"
  },
  
  ready: function () {
    let self = this
    self.getDescList()
  },

  /**
   * 组件的方法列表
   */
  methods: {
    closeDesc: function () {
      let self = this
      self.triggerEvent('closedesc')
    },
    getDescList: function () {
      let self = this
      wx.request({
        url: utils.default.host + '/api/decorate/getDecorateList.json?versionId=' + utils.default.versionId + '&code=AMULET_PACKAGE_ILLUSTRATE',
        success: function (res) {
          if (res.data.success) {
            res.data.result.forEach(function(e, i) {
              let wList = e.text.split('?')
              let a = wList[wList.length-1]
              delete wList[wList.length - 1]
              let q = wList.join('？')
              res.data.result[i].a = a
              res.data.result[i].q = q
              res.data.result[i].decorateImageVoList[0].imageUrl = utils.default.imgHost + res.data.result[i].decorateImageVoList[0].imageUrl
            })
            self.setData({
              descList: res.data.result
            })
          }
        }
      })
    }
  }
})
